//------------------------------------------------------------------------------
#include <QApplication>
#include <QTranslator>
#include <QTextCodec>
#include "CMainFrm.h"
#include "version.h"
//------------------------------------------------------------------------------
int main(int argc, char *argv[])
{
	int res=0;
	int profilIndex;
	QString profilName="";
	CMainFrm *mainFrm;
	QTranslator translator;
	
	QApplication app(argc, argv);
	
	QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
	QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8"));
	
#ifdef WIN32
	QApplication::addLibraryPath(QApplication::applicationDirPath());
#endif //WIN32
	
	app.setApplicationName("coMexpert");
	app.setApplicationVersion(VERSION_LOGICIEL);
	app.setOrganizationName("Alpes Ressources");
	app.setOrganizationDomain("alpes-ressources.com");
	
	if((profilIndex=app.arguments().indexOf("-p")) != -1 && profilIndex+1 < app.arguments().size())
	{
		profilName=app.arguments().at(profilIndex+1);
	}

	mainFrm=new CMainFrm(NULL, profilName);
	mainFrm->setWindowTitle(QObject::tr("coMexpert - version ")+VERSION_LOGICIEL);
	mainFrm->showMaximized();
	mainFrm->authentification();
	if(mainFrm->getVersion() != VERSION_LOGICIEL)
	{
		mainFrm->showNotesDeVersion();
		mainFrm->setVersion(VERSION_LOGICIEL);
	}
	translator.load(QString("qt_fr"), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
	
	app.installTranslator(&translator);
	res=app.exec();
	
	return res;
}
//------------------------------------------------------------------------------
